"""
导包
获取测试需要接口字段数据
请求返回结果

"""

import os
import requests
class configHttp:
    def __init__(self,method,interfaceUrl,value):
        self.method=method
        self.interfaceUrl=interfaceUrl
        self.value=eval(value)

    def http(self):
        if self.method.lower()=='post':
            return self.__post()
        elif self.method.lower()=='get':
            return self.__get()

    def __post(self):
        re=requests.post(url=self.interfaceUrl,data=self.value)
        return re

    def __get(self):
        re=requests.get(url=self.interfaceUrl,params=self.value)
        return  re

if __name__ == '__main__':
    url = "https://www.wanandroid.com/user/login"
    method = 'post'
    value = "{'username': 'liangchao', 'password': '123456'}"
    con=configHttp(method,url,value)
    re=con.http()
    print(re.text)
    print(re.status_code)
